<template>
  <div class="dashboard-container">
    <div class="app-container">
      <el-card>
        <el-tabs>
          <el-tab-pane label="登录账户设置">
            <!-- 放置表单 -->
            <el-form
              label-width="120px"
              style="margin-left: 120px; margin-top: 30px"
            >
              <el-form-item label="姓名:">
                <el-input v-model="userInfo.username" style="width: 300px" />
              </el-form-item>
              <el-form-item label="密码:">
                <el-input
                  v-model="userInfo.password"
                  style="width: 300px"
                  type="password"
                />
              </el-form-item>
              <el-form-item>
                <el-button type="primary" @click="save">更新</el-button>
              </el-form-item>
            </el-form>
          </el-tab-pane>
          <el-tab-pane label="个人详情">
            <!-- 放置个人详情 -->
            <!-- <component :is="'UserInfo'" /> -->
            <user-info />
          </el-tab-pane>
          <el-tab-pane label="岗位信息">
            <!-- 放置个人详情 -->
            <!-- <component :is="userComponent" /> -->
            <job-info />
          </el-tab-pane>
        </el-tabs>
      </el-card>
    </div>
  </div>
</template>

<script>
// 获取 用户的 基本 信息
import { getUserBaseInfoById } from '@/api/user.js'
// 保存用户信息到 服务端
import { pubDetailById } from '@/api/employees.js'
// 导入 用户信息 组件
import UserInfo from './components/user-info.vue'
// 导入 岗位信息 组件
import JobInfo from './components/job-info.vue'
export default {
  name: 'Salarys',
  components: {
    UserInfo,
    JobInfo
  },
  props: {},
  data() {
    return {
      // 切换 动态组件
      userComponent: '',
      // 放置员工基本 信息
      userInfo: []
    }
  },
  created() {
    this.getUserBaseInfoById()
  },
  mounted() {},
  methods: {
    //   获取到 用户数据
    async getUserBaseInfoById() {
      const res = await getUserBaseInfoById(this.$route.params.id)
      this.userInfo = res
      this.userInfo.password = ''
      console.log(res)
    },
    async save() {
      await pubDetailById(this.userInfo)
      this.$message.success('更新成功')
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
